package com.allwees.bs.module.mms.wf;

import com.baomidou.mybatisplus.core.enums.IEnum;
import com.allwees.core.wf.FsmState;
import com.allwees.core.wf.Transition;

import java.util.Arrays;
import java.util.List;

/**
 * 零售商审核流程状态机
 *
 * @author mouhaining
 * @since 2019-12-13
 */
public enum ESupplierState implements FsmState<ESupplierState, ERetailerAction>, IEnum<String> {
    START("Start", false, false) {
        @Override
        public List<Transition<ESupplierState, ERetailerAction>> getTransitions() {
            return Arrays.asList(
                    new Transition<>(ERetailerAction.SYSTEM_CREATED, COMPLETED)
            );
        }
    },

    COMPLETED("Completed", false, true);

    /**
     * 状态描述
     */
    private String desc;

    private boolean started;

    private boolean ended;

    /**
     * 数据库存储用值
     */
    public String key() {
        return name();
    }

    public String desc() {
        return desc;
    }

    @Override
    public boolean started() {
        return started;
    }

    @Override
    public boolean ended() {
        return ended;
    }

    ESupplierState(String desc, boolean started, boolean ended) {
        this.desc = desc;
        this.started = started;
        this.ended = ended;
    }

    @Override
    public String getValue() {
        return name();
    }
}
